
$MOD51
	ORG	00H
MAIN:
lcall	kieu_1
lcall	kieu_2
lcall	kieu_3
lcall	kieu_4
lcall	kieu_5
lcall	kieu_6
ljmp main

kieu_1:

	MOV	R0,#00H
	;TAT TAT CA CAC PORT
	mov 	p0,#00H 
	MOV	P1,#00H
	MOV	P2,#00H
	MOV 	P3,#00H
STAR1:
	
	MOV	DPTR,#DATADISP1 ;CSDL DIEU KHIEN CAC BIT
	MOV	A,R0
	MOVC	A,@A+DPTR
	MOV	P0,A ; PORT DUOC NAP DU LIEU VAO
	
	;DIEU KHIEN PORT 3
	MOV	DPTR,#DATADISP2 ;CSDL DIEU KHIEN CAC BIT
	MOV	A,R0
	MOVC	A,@A+DPTR
	MOV 	P1,A ; PORT DUOC NAP DU LIEU VAO
	LCALL	DELAY1
	INC R0
	CJNE	R0,#120,star1 ;THAY DOI SO NAY THEO CSDL
	RET

kieu_2:

	MOV	R0,#00H
	;TAT TAT CA CAC PORT
	mov 	p0,#00H 
	MOV	P1,#00H
	MOV	P2,#00H
	MOV 	P3,#00H
STAR2:
	
	MOV	DPTR,#DATADISP1 ;CSDL DIEU KHIEN CAC BIT
	MOV	A,R0
	MOVC	A,@A+DPTR
	MOV	P0,A ; PORT DUOC NAP DU LIEU VAO
	
	;DIEU KHIEN PORT 3
	MOV	DPTR,#DATADISP2 ;CSDL DIEU KHIEN CAC BIT
	MOV	A,R0
	MOVC	A,@A+DPTR
	MOV 	P1,A ; PORT DUOC NAP DU LIEU VAO
	LCALL	DELAY2
	INC R0
	CJNE	R0,#120,star2 ;THAY DOI SO NAY THEO CSDL
	RET

kieu_3:

	MOV	R0,#00H
	;TAT TAT CA CAC PORT
	mov 	p0,#00H 
	MOV	P1,#00H
	MOV	P2,#00H
	MOV 	P3,#00H
STAR3:
	
	MOV	DPTR,#DATADISP1 ;CSDL DIEU KHIEN CAC BIT
	MOV	A,R0
	MOVC	A,@A+DPTR
	MOV	P0,A ; PORT DUOC NAP DU LIEU VAO
	
	;DIEU KHIEN PORT 3
	MOV	DPTR,#DATADISP2 ;CSDL DIEU KHIEN CAC BIT
	MOV	A,R0
	MOVC	A,@A+DPTR
	MOV 	P1,A ; PORT DUOC NAP DU LIEU VAO
	LCALL	DELAY3
	INC R0
	CJNE	R0,#120,star3 ;THAY DOI SO NAY THEO CSDL
	RET

kieu_4:

	MOV	R0,#00H
	;TAT TAT CA CAC PORT
	mov 	p0,#00H 
	MOV	P1,#00H
	MOV	P2,#00H
	MOV 	P3,#00H
STAR4:
	
	MOV	DPTR,#DATADISP1 ;CSDL DIEU KHIEN CAC BIT
	MOV	A,R0
	MOVC	A,@A+DPTR
	MOV	P0,A ; PORT DUOC NAP DU LIEU VAO
	
	;DIEU KHIEN PORT 3
	MOV	DPTR,#DATADISP2 ;CSDL DIEU KHIEN CAC BIT
	MOV	A,R0
	MOVC	A,@A+DPTR
	MOV 	P1,A ; PORT DUOC NAP DU LIEU VAO
	LCALL	DELAY4
	INC R0
	CJNE	R0,#120,star4 ;THAY DOI SO NAY THEO CSDL
	RET

kieu_5:

	MOV	R0,#00H
	;TAT TAT CA CAC PORT
	mov 	p0,#00H 
	MOV	P1,#00H
	MOV	P2,#00H
	MOV 	P3,#00H
STAR5:
	
	MOV	DPTR,#DATADISP1 ;CSDL DIEU KHIEN CAC BIT
	MOV	A,R0
	MOVC	A,@A+DPTR
	MOV	P0,A ; PORT DUOC NAP DU LIEU VAO
	
	;DIEU KHIEN PORT 3
	MOV	DPTR,#DATADISP2 ;CSDL DIEU KHIEN CAC BIT
	MOV	A,R0
	MOVC	A,@A+DPTR
	MOV 	P1,A ; PORT DUOC NAP DU LIEU VAO
	LCALL	DELAY5
	INC R0
	CJNE	R0,#120,star5 ;THAY DOI SO NAY THEO CSDL
	RET

kieu_6:

	MOV	R0,#00H
	;TAT TAT CA CAC PORT
	mov 	p0,#00H 
	MOV	P1,#00H
	MOV	P2,#00H
	MOV 	P3,#00H
STAR6:
	
	MOV	DPTR,#DATADISP1 ;CSDL DIEU KHIEN CAC BIT
	MOV	A,R0
	MOVC	A,@A+DPTR
	MOV	P0,A ; PORT DUOC NAP DU LIEU VAO
	
	;DIEU KHIEN PORT 3
	MOV	DPTR,#DATADISP2 ;CSDL DIEU KHIEN CAC BIT
	MOV	A,R0
	MOVC	A,@A+DPTR
	MOV 	P1,A ; PORT DUOC NAP DU LIEU VAO
	LCALL	DELAY6
	INC R0
	CJNE	R0,#120,star6 ;THAY DOI SO NAY THEO CSDL
	RET




;------------------------
;nhom lenh cac vong lap
DELAY1:
	PUSH	00H
	MOV	R0,#70
	MOV	TMOD,#01H
LOOP1:
	MOV	TH0,#HIGH(-8000);CHINH TOC DO
	MOV	TL0,#LOW(-8000);CHINH TOC DO
	SETB	TR0
 	JNB	TF0,$
	CLR	TR0
	CLR	TF0
	DJNZ	R0,LOOP1
	POP	00H
	RET
DELAY2:
	PUSH	00H
	MOV	R0,#70
	MOV	TMOD,#01H
LOOP2:
	MOV	TH0,#HIGH(-800)
	MOV	TL0,#LOW(-800)
	SETB	TR0
 	JNB	TF0,$
	CLR	TR0
	CLR	TF0
	DJNZ	R0,LOOP2
	POP	00H
	RET
DELAY3:
	PUSH	00H
	MOV	R0,#70
	MOV	TMOD,#01H
LOOP3:
	MOV	TH0,#HIGH(-600)
	MOV	TL0,#LOW(-600)
	SETB	TR0
 	JNB	TF0,$
	CLR	TR0
	CLR	TF0
	DJNZ	R0,LOOP3
	POP	00H
	RET
DELAY4:
	PUSH	00H
	MOV	R0,#70
	MOV	TMOD,#01H
LOOP4:
	MOV	TH0,#HIGH(-300)
	MOV	TL0,#LOW(-300)
	SETB	TR0
 	JNB	TF0,$
	CLR	TR0
	CLR	TF0
	DJNZ	R0,LOOP4
	POP	00H
	RET
DELAY5:
	PUSH	00H
	MOV	R0,#70
	MOV	TMOD,#01H
LOOP5:
	MOV	TH0,#HIGH(-90)
	MOV	TL0,#LOW(-90)
	SETB	TR0
 	JNB	TF0,$
	CLR	TR0
	CLR	TF0
	DJNZ	R0,LOOP5
	POP	00H
	RET
DELAY6:
	PUSH	00H
	MOV	R0,#70
	MOV	TMOD,#01H
LOOP6:
	MOV	TH0,#HIGH(-50)
	MOV	TL0,#LOW(-50)
	SETB	TR0
 	JNB	TF0,$
	CLR	TR0
	CLR	TF0
	DJNZ	R0,LOOP6
	POP	00H
	RET

;-----------------------------------
;du lieu dung de dieu khien

DATADISP1:
DB	00000001B,00000010B,00000100B,00001000B,00000001B,00000010B,00000100B,00001000B,
DB	00000001B,00000010B,00000100B,00001000B,00000001B,00000010B,00000100B,00001000B,
DB	00000001B,00000010B,00000100B,00001000B,00000001B,00000010B,00000100B,00001000B,
DB	00000001B,00000010B,00000100B,00001000B,00000001B,00000010B,00000100B,00001000B,
DB	00000001B,00000010B,00000100B,00001000B,00000001B,00000010B,00000100B,00001000B,
DB	00000001B,00000010B,00000100B,00001000B,00000001B,00000010B,00000100B,00001000B,
DB	00000001B,00000010B,00000100B,00001000B,00000001B,00000010B,00000100B,00001000B,
DB	00000001B,00000010B,00000100B,00001000B,00000001B,00000010B,00000100B,00001000B,
DB	00000001B,00000010B,00000100B,00001000B,00000001B,00000010B,00000100B,00001000B,
DB	00000001B,00000010B,00000100B,00001000B,00000001B,00000010B,00000100B,00001000B,
DB	00001111B,00001111B,00001111B,00001111B,00001110B,00001101B,00001011B,00000111B,
DB	00001110B,00001101B,00001011B,00000111B,00001110B,00001101B,00001011B,00000111B,
DB	00001110B,00001101B,00001011B,00000111B,00001110B,00001101B,00001011B,00000111B,
DB	00001110B,00001101B,00001011B,00000111B,00001110B,00001101B,00001011B,00000111B,
DB	00001110B,00001101B,00001011B,00000111B,00001110B,00001101B,00001011B,00000111B,

DATADISP2:
DB	00000001B,00000010B,00000100B,00001000B,00001000B,00000100B,00000010B,00000001B,
DB	00000001B,00000010B,00000100B,00001000B,00001000B,00000100B,00000010B,00000001B,
DB	00000001B,00000011B,00000111B,00001111B,00001111B,00001111B,00001111B,00001111B,
DB	00001111B,00001111B,00001111B,00001111B,00001111B,00001111B,00001111B,00001111B,
DB	00001110B,00001111B,00001110B,00001111B,00001101B,00001111B,00001101B,00001111B,
DB	00001011B,00001111B,00001011B,00001111B,00000111B,00001111B,00000111B,00001111B,
DB	00001111B,00001111B,00001111B,00001111B,00000000B,00001111B,00000000B,00001111B,
DB	00000000B,00001111B,00000000B,00001111B,00001111B,00001111B,00001111B,00001111B,
DB	00001111B,00001111B,00001111B,00001111B,00001111B,00001111B,00001111B,00001111B,
DB	00001111B,00001111B,00001111B,00001111B,00001111B,00001111B,00001111B,00001111B,
DB	00001111B,00001111B,00001111B,00001111B,00001111B,00001111B,00001111B,00001111B,
DB	00000001B,00000010B,00000100B,00001000B,00001000B,00000100B,00000010B,00000001B,
DB	00000001B,00000010B,00000100B,00001000B,00001000B,00000100B,00000010B,00000001B,
DB	00000001B,00000010B,00000100B,00001000B,00001000B,00000100B,00000010B,00000001B,
DB	00000001B,00000010B,00000100B,00001000B,00001000B,00000100B,00000010B,00000001B,

end


